/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package music.Chords;

import MidiGui.MusicFonts;
import java.awt.Graphics;
import java.util.TreeMap;
import music.types.MidiNote;

/**
 *
 * @author TJ
 */
public class SixStringDiagram extends GuitarChordDiagram{
    public SixStringDiagram(int frets) {
        super(new MidiNote[]{new MidiNote(52,"E"),new MidiNote(57,"A"),new MidiNote(62,"D"),
                new MidiNote(67,"G"),new MidiNote(71,"B"),new MidiNote(76,"E")
        },frets,4);
    }
    @Override
    public void render(Graphics g) {
       MusicFonts.getFont("OpusSpecial");
       g.drawString(""+(char)0xB6, 0, 0);
    }
    public boolean[][] getNotes(Chord c) {
        boolean[][] ret=new boolean[6][getFrets()+1];
        for(int i=0; i<=getFrets();i++) {
            for(int j=0; j<6; j++){
                ret[j][i]=noteInChord(c,getTuning()[j].getMidi()+i);
            }
        }
        return ret;
    }
    public boolean[][] getDiagram(int start,int stretch,boolean[][] allnotes) {
        if(start<=0 || start+stretch>=getFrets()+1){
            throw new IllegalArgumentException();
        }
        boolean[][] ret=new boolean[6][stretch+1];
        for(int i=0; i<6; i++){
            ret[i][0]=allnotes[i][0];
        }
        for(int i=start; i<start+stretch;i++) {
            for(int j=0; j<6; j++){
                ret[j][i-start+1]=allnotes[j][i];
            }
        }
        return ret;
    }
    private boolean noteInChord(Chord c, int midiNote){
        for(MidiNote n : c.getNotes()) {
            if(n.getMidi()%12==midiNote%12){return true;}
        }
        return false;
    }
    @Override
    public void generateDiagram() {
        boolean[][] availNotes;
        TreeMap<Integer,Integer> notes=new TreeMap<Integer,Integer>();
        for(MidiNote n : getChord().getNotes()) {
            notes.put(n.getMidi()%12, 0);
        }
       //Vector<Integer>[] validFrets
        for(int j=0; j<getTuning().length;j++) {
            MidiNote n=getTuning()[j];
            for(int i=0; i<getFrets()+1;i++) {
                if(notes.containsKey((i+n.getMidi())%12)){
                    
                }
            }
        }
    }
    
}
